﻿Public Class ClimSite
    Dim idClima As Integer
    Dim db As New Connexion
    Dim action As String
    Dim Entrer As String
    Public databaseName As String
    Private Sub Vents_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Vents.Click
        majour()
    End Sub

    Private Sub ButtonEnregistrer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonEnregistrer.Click
        Try
            Entrer = ""
            db.myReq = "INSERT INTO  [dbo].[CLIMSITE]([ID_Sit],[DESCRP_CLIMG],[DESCRT_CLIMG],[DESCRB_CLIMG] ,[DESCRG_CLIMG],[DESCRV_CLIMG]) VALUES('" & db.idSite & "','" & Me.TextBoxDesc1.Text & "','" & Me.TextBoxDesc2.Text & "','" & Me.TextBoxDesc3.Text & "','" & Me.TextBoxDesc4.Text & "','" & Me.TextBoxDesc5.Text & "')"
            db.Connecter(databaseName)
            db.Disconnecter()
            db.myReq = "SELECT Max([Id_ClimSite]) FROM  [dbo].[CLIMSITE]"
            db.Connecter(databaseName)

            While db.rdr.Read()
                idClima = db.rdr(0)
            End While
        Catch ex As Exception
            MsgBox("Problème de connexion")
        End Try
    End Sub

    Private Sub ButtonNouv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonNouv.Click
        Dim intImporter As New ImporterStationClim
        intImporter.idClima = idClima
        intImporter.Visible = True
    End Sub

    Private Sub majour()
        Try
            db.myReq = "SELECT * FROM  [dbo].[ClimSite_StatMeteo] where [Id_ClimSite]='" & idClima & "'"
            db.Connecter(databaseName)
            Me.DataGridView2.Rows.Clear()
            While db.rdr.Read()
                DataGridView2.Rows.Add(db.rdr(0), db.rdr(1), db.rdr(2))
            End While
            db.Disconnecter()

        Catch ex As Exception
            MsgBox("Problème de connexion")
        End Try
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Me.Close()

    End Sub

    Private Sub ButtonMod_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonMod.Click

    End Sub
End Class